<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/jquery-3.5.1.min.js"></script>
    <script src="./js/template-web.js"></script>
  </head>
  <body>
    <table>
      <thead>
        <tr>
          <th>名字</th>
          <th>皮肤</th>
          <th>按钮</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>ez</td>
          <td>未来战士</td>
          <td><button>删除</button></td>
        </tr>
      </tbody>
    </table>
    <script type="text/html" id="id">
      {{each data}}
      <tr>
        <td>{{$value.name}}</td>
        <td>{{$value.skinname}}</td>
        <td>
          <button id="delate">删除</button>
          <button id="app">增加</button>
        </td>
      </tr>

      {{/each}}
    </script>
    <script>
      $.ajax({
        type: "get",
        url: "http://127.0.0.1:8000/getHeroSkin",
        success: (res) => {
          console.log(res);
          let data = JSON.parse(res);
          let str = template("id", { data });
          $("tbody").html(str);
        },
      });
      $('tbody').on('click','#delate',function(){
        $.ajax({
        type: "get",
        url: "http://127.0.0.1:8000/getHeroSkin",
        success: (res) => {
          console.log(res);
          let data = JSON.parse(res);
          let str = template("id", { data });
          $("tbody").html(str);
        },
      });
      })
    </script>
  </body>
</html>
